package com.miaomiao.utils;

import cn.hutool.core.util.RandomUtil;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;

public class IDUtil {

    /**
     * id生成工具
     * @param length(范围限制1-9的整数)
     * @return
     */
    public static Long generateId(Integer length) {
        String id = null;
        SimpleDateFormat sf = new SimpleDateFormat("yyyyMM");
        String temp = sf.format(new Date());
        //获取6位随机数
        id = temp + RandomUtil.randomNumbers(length);
        return Long.valueOf(id);
    }
}
